fix: allow retrying partial worktree removal - #3315
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughWorktree removal now requests force confirmation for matching Suggested reviewers: Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to The recovery flow only permits removal after explicit confirmation and preserves the existing safety checks for leftover directories. No merge-blocking risk is identified. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
0b02595 to
c70825e
Compare
Greptile SummaryThis PR allows an interrupted worktree removal to be retried when Git has already unregistered the checkout but left its directory behind.
Confidence Score: 5/5The PR appears safe to merge because the new retry state remains explicitly confirmed and the existing forced-cleanup guards continue to reject registered or unrelated directories. The change only enables confirmation after a recognized partial-removal error; operation identity and path matching protect modal state, and filesystem cleanup remains gated by registration and repository-identity checks.
|
| Filename | Overview |
|---|---|
| src/app/api/worktrees/deferred.rs | Extends deferred removal error handling to request explicit force confirmation for recognized partial-removal errors while retaining existing response semantics and path/state matching. |
| src/app/api/worktrees.rs | Adds focused regression coverage verifying the response, pending-operation cleanup, modal transition, and preservation of workspace and event state. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Deferred worktree removal] --> B{Git result}
B -->|Success| C[Remove workspace and emit events]
B -->|Dirty checkout| D[Return dirty_worktree_requires_force]
B -->|Not a working tree| E[Return worktree_remove_failed]
D --> F[Show explicit force confirmation]
E --> F
F --> G[Confirmed forced retry]
G --> H{Path still registered or unrelated?}
H -->|Yes| I[Reject cleanup]
H -->|No, valid repository leftover| J[Remove leftover directory]
Reviews (1): Last reviewed commit: "fix: allow retrying partial worktree rem..." | Re-trigger Greptile
|
@akbash-bot check if the feature is still needed, rebase and resolve conflicts, then get CI/reviews happy |
c70825e to
d4cd005
Compare
|
Still needed: the regression test fails on current master when an open removal dialog receives Git’s “not a working tree” error. Rebased onto d184b41 and ported the fix to the client-owned dialog in d4cd005; server/API and deletion safeguards remain unchanged. Full The generic docstring warning counts four files, but this refreshed diff touches two and adds no function. I am leaving unrelated documentation unchanged. Ready for maintainer review. Scope remains retrying within the open dialog; reopening after the checkout disappears from Git’s list is not addressed here. |
refs herdrdev#3314 Co-authored-by: akbash-bot <300245827+akbash-bot@users.noreply.github.com>
Issue
After Git unregisters a worktree but cannot delete its directory, retrying removal in the open dialog keeps showing an error.
Problem
Git reports that the checkout is no longer a working tree. The dialog only offered force confirmation for dirty checkouts, leaving guarded recovery inaccessible from this retry state.
How did we fix it?
Herdr now offers explicit force confirmation for this removal error. The fix lives in the client-owned dialog after the TUI migration. API responses and filesystem safety checks are unchanged. Reopening a fresh dialog after the checkout disappears from Git's list remains outside this fix.
Verification
The current client interaction test failed before the fix and passes afterward. It checks the warning, explicit forced retry, no automatic retry, unrelated errors, forced errors, and cancellation. All 17 targeted removal tests and full
just checkpass, including 3,402 Rust tests, Windows cross-lint, maintenance, integration assets, and docs checks.refs #3314